package com.example.controller;

import com.example.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1")
public class TestController {

    @Autowired
    private RedisUtil redisUtil;

    @Qualifier("redisTemplate")
    @Autowired
    private RedisTemplate redisTemplateOne;

    @Qualifier("redisTemplateTwo")
    @Autowired
    private RedisTemplate redisTemplateTwo;

    @RequestMapping("/serRedis")
    public String setRedis(){
        redisUtil.set("123456","测试过期时间",10L);
        redisUtil.set("order_124343","测试过期时间",10L);
        return "ok";
    }

    @RequestMapping("/setMultRedis")
    public String setMultRedis(){
        redisTemplateOne.opsForValue().set("redis1", "redis1");
        redisTemplateTwo.opsForValue().set("redis2", "redis2");
        return "ok";

    }
}
